<template>
  <el-row class="tac">
    <el-col :span="5">
      <el-menu
        :default-active="currentMenu"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        @select="handleSelect"
      >
        <router-link :to="{ name: 'ReplyMeMsg' }">
          <el-menu-item index="1">
            <i class="el-icon-s-comment"></i>
            <span slot="title"
              >回复我的
              <el-badge
                :value="replyCommentTotal"
                :max="99"
                :hidden="replyCommentTotal ? false : true"
                class="item"
              >
              </el-badge
            ></span>
          </el-menu-item>
        </router-link>

        <router-link :to="{ name: 'ThumbsUpMsg' }">
          <el-menu-item index="3">
            <i class="el-icon-s-opportunity"></i>
            <span slot="title">
              收到的赞
              <el-badge
                :value="likeTotal"
                :max="99"
                :hidden="likeTotal ? false : true"
                class="item"
              >
              </el-badge
            ></span>
          </el-menu-item>
        </router-link>

        <!-- <router-link :to="{ name: 'SystemMsg' }">
          <el-menu-item index="2">
            <i class="el-icon-bell"></i>
            <span slot="title">系统通知</span>
          </el-menu-item>
        </router-link> -->
      </el-menu>
    </el-col>

    <el-col :span="16">
      <router-view></router-view>
    </el-col>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      replyCommentTotal: 0,
      likeTotal: 0,
    };
  },
  computed: {
    // 计算 进入url对应菜单css选中
    currentMenu() {
      const urlsub = this.$route.path;
      if (urlsub === "/ReplyMeMsg") return "1";
      else if (urlsub === "/SystemMsg") return "2";
      else return "3";
    },
  },
  methods: {
    calActiveIdx() {
      return 3;
    },
    handleSelect(key, keyPath) {},
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
  mounted() {
    const infoData = window.localStorage.getItem("info");
    if (infoData) {
      this.replyCommentTotal = parseInt(JSON.parse(infoData).replyCommentTotal);
      this.likeTotal = parseInt(JSON.parse(infoData).likeTotal);
    }
  },
};
</script>
